Ektron CMS400.Net Reference

>>Using Widgets > Customizing Widgets > Adding a Field to a Widget

Adding a Field to a Widget

This section provides an example of adding a Content type drop down to the List Summary widget. The drop down lets the person dropping the widget on the page select from these choices.

Here is what the drop down looks like once it is implemented.

To add this drop down to the List Summary widget, follow these steps.

  1. In Visual Studio, open the ListSummary widget, site root/widgets/ListSummary.ascx.
  2. Find the text DisplaySelectedContent.
  3. Below DisplaySelectedContent, add the following code to create a drop down list for the ContentType property.
  4. Save the ListSummary.ascx file.
  5. Open the codebehind file, ListSummary.ascx.cs.
  6. In the properties region, declare a string variable for the ContentType property, as shown below.

    private string _ContentType;

  7. Create a local property with default setting of AllTypes, as shown below.

    [WidgetDataMember("AllTypes")]

    public string ContentType { get { return _ContentType; } set { _ContentType = value; } }

  8. In the EditEvent area, set the select list's value to ContentType.

    ContentTypeList.SelectedValue = ContentType;

  9. In the SaveButton_Click event, set ContentType as the select list's value.

    ContentType = ContentTypeList.SelectedValue;

  10. In the SetListSummary() function, set the List Summary server control's ContentType to the CMSContentType property.

    ListSummary1.ContentType = (CMSContentType)Enum.Parse(typeof(CMSContentType), ContentType);

  11. Save the ListSummary.ascx.cs file.

Visit the Ektron Dev Center at http://dev.ektron.com 1-866 - 4 - EKTRON

Ektron CMS400.NET Reference Version 8.02 SP1 Rev 1

Ektron Documentation,© 2011 Ektron, Inc.